#!/bin/sh
# run as: sudo ./setup_qt3d $USER  
numargs=$#
this_script=$0
username=$1

. ./source_me

if [ "$numargs" = 0 ]; then
  username=$USER
  echo "re-running script as root..."
  sudo ./$this_script $USER # re-run this script as root, passing in the username of the original caller
  echo "finished running as root."
  exit $?
fi


if [ "$?" -ne 0 ]; then
  exit $?
fi


# qt3d
########################################################################################################
#./setup_qt3d $username
cd $BASE_DIR
sudo -u $username git clone git://gitorious.org/qt/qt3d.git 
#if [ "$?" -ne 0 ]; then
#  exit $?
#fi

echo $PATH
cd $BASE_DIR/qt3d
#patch -N src/threed/painting/qglpainter.cpp < ../openmining/third_party_patches/patch.qglpainter.cpp
sudo -u $username $QMAKE
if [ "$?" -ne 0 ]; then
  exit $?
fi

sudo -u $username make
if [ "$?" -ne 0 ]; then
  exit $?
fi

make install
if [ "$?" -ne 0 ]; then
  exit $?
fi

 

